//-----------------------------------------------------------------------
// <copyright file="Create.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
// </copyright>
// <summary>Creates the ZipFile specified.</summary>
//-----------------------------------------------------------------------
namespace Microsoft.Sdc.Tasks.Zip
{
    using System;
    using Microsoft.Build.Framework;

    /// <summary>
    /// Create the specified zip file using J# 2.0.
    /// </summary>
    /// <remarks>
    /// <code><![CDATA[<Zip.Create pathToZipFile="zipFile"/>]]></code>
    /// <para>where:</para>
    /// <para><i>pathToZipFile (Required)</i></para>
    /// <para>The path to the zip file to be created.</para>
    /// </remarks>
    /// <example>
    /// <code><![CDATA[
    /// <Project>
    ///     <Target Name="Test" >
    ///         <Zip.Create pathToZipFile="c:\newzip.zip" />
    ///     </Target>
    /// </Project>
    /// ]]></code>    
    /// </example>    
    public class Create : TaskBase
    {
        private string pathToZipFile = String.Empty;

        /// <summary>
        /// Specifies the path and filename of the zip file to be created
        /// </summary>
        /// <value>The path and file name for the new zip file.</value>
        [Required]
        public string PathToZipFile
        {
            get { return this.pathToZipFile ?? String.Empty; }
            set { this.pathToZipFile = value; }
        }

        /// <summary>
        /// Performs the action of this task.
        /// </summary>
        protected override void InternalExecute()
        {
            this.Log.LogMessageFromResources("Zip.Create", this.pathToZipFile);
            ZipManager.Create(this.pathToZipFile);
        }
    }
}